package com.kakarote.hrm.constant;

import java.util.ArrayList;
import java.util.List;

/**
 * 招聘岗位常量类
 *
 * @author system
 * @since 2024-01-01
 */
public class RecruitPositionConstant {

    /**
     * 岗位类别枚举
     */
    public enum PositionTypeEnum {
        MANAGEMENT(1, "管理岗"),
        TECHNICAL(2, "专技岗"),
        SERVICE(3, "工勤岗");

        private final Integer type;
        private final String name;

        PositionTypeEnum(Integer type, String name) {
            this.type = type;
            this.name = name;
        }

        public Integer getType() {
            return type;
        }

        public String getName() {
            return name;
        }

        public static String getNameByType(Integer type) {
            if (type == null) {
                return "";
            }
            for (PositionTypeEnum positionType : values()) {
                if (positionType.getType().equals(type)) {
                    return positionType.getName();
                }
            }
            return "";
        }

        public static Integer getTypeByName(String name) {
            if (name == null) {
                return null;
            }
            for (PositionTypeEnum positionType : values()) {
                if (positionType.getName().equals(name)) {
                    return positionType.getType();
                }
            }
            return null;
        }

        /**
         * 获取所有类别
         */
        public static List<String> getAllTypeNameList() {
            PositionTypeEnum[] values = PositionTypeEnum.values();
            ArrayList<String> strings = new ArrayList<>();
            for (PositionTypeEnum value : values) {
                strings.add(value.getName());
            }
            return strings;
        }
    }

    /**
     * 招聘渠道枚举
     */
    public enum PositionChannelEnum {
        CAMPUS(1, "校招"),
        SOCIAL(2, "社招");

        private final Integer channel;
        private final String name;

        PositionChannelEnum(Integer channel, String name) {
            this.channel = channel;
            this.name = name;
        }

        public Integer getChannel() {
            return channel;
        }

        public String getName() {
            return name;
        }

        public static String getNameByChannel(Integer channel) {
            if (channel == null) {
                return "";
            }
            for (PositionChannelEnum positionChannel : values()) {
                if (positionChannel.getChannel().equals(channel)) {
                    return positionChannel.getName();
                }
            }
            return "";
        }

        public static Integer getChannelByName(String name) {
            if (name == null) {
                return null;
            }
            for (PositionChannelEnum positionChannel : values()) {
                if (positionChannel.getName().equals(name)) {
                    return positionChannel.getChannel();
                }
            }
            return null;
        }

        /**
         * 获取所有渠道
         */
        public static List<String> getAllChannelNameList() {
            PositionChannelEnum[] values = PositionChannelEnum.values();
            ArrayList<String> strings = new ArrayList<>();
            for (PositionChannelEnum value : values) {
                strings.add(value.getName());
            }
            return strings;
        }
    }
}
